module omg(keyPressed, validkey, lcdKey, cursor, ledg);

input [15:0] keyPressed; // 8-bit keyboard code (input)
output validkey;
reg validkey;
output [7:0] lcdKey; // 8-bit character for lcd display (output)
reg [7:0] lcdKey;
output [4:0] cursor;
reg [4:0] cursor;
output[8:0] ledg;
reg[8:0] ledg;

parameter pressedA = 16'HF01C;
parameter pressedB = 16'HF032;
parameter pressedC = 16'hF021;
parameter pressedD = 16'hF023;
parameter pressedE = 16'hF024;
parameter pressedF = 16'hF02B;
parameter pressedG = 16'hF034;
parameter pressedH = 16'hF033;
parameter pressedI = 16'hF043;
parameter pressedJ = 16'hF03B;
parameter pressedK = 16'hF042;
parameter pressedL = 16'hF04B;
parameter pressedM = 16'hF03A;
parameter pressedN = 16'hF031;
parameter pressedO = 16'hF044;
parameter pressedP = 16'hF04D;
parameter pressedQ = 16'hF015;
parameter pressedR = 16'hF02D;
parameter pressedS = 16'Hf01B;
parameter pressedT = 16'Hf02C;
parameter pressedU = 16'hF03C;
parameter pressedV = 16'hF02A;
parameter pressedW = 16'hF01D;
parameter pressedX = 16'hF022;
parameter pressedY = 16'hF035;
parameter pressedZ = 16'hF01A;
parameter pressedENTER = 16'hF05A;
parameter pressedSPACE = 16'hF029;
parameter pressedBACK	= 16'hF066;

always@(*)
begin
	case (keyPressed)
			
			pressedA:
			begin
				lcdKey = 8'h41;
				validkey = 1'b1;
			end
			
			pressedB:
			begin
				lcdKey = 8'h42;
				validkey = 1'b1;
				if (cursor < 5'd32)
				begin
					//cursor = cursor + 5'd1;
					ledg[0] = 1'b1;
					ledg[1] = 1'b0;
				end
				else
				begin
					//cursor = 5'd0;
					ledg[0] = 1'b0;
					ledg[1] = 1'b1; // why would this be on initially?
				end
			end
			
			pressedC:
			begin
				lcdKey = 8'h43;
				validkey = 1'b1;
			end
			
			pressedD:
			begin
				lcdKey = 8'h44;
				validkey = 1'b1;
			end
			
			pressedE:
			begin
				lcdKey = 8'h45;
				validkey = 1'b1;
			end
			
			pressedF:
			begin
				lcdKey = 8'h46;
				validkey = 1'b1;
			end
			
			pressedG:
			begin
				lcdKey = 8'h47;
				validkey = 1'b1;
			end
			
			pressedH:
			begin
				lcdKey = 8'h48;
				validkey = 1'b1;
			end
			
			pressedI:
			begin
				lcdKey = 8'h49;
				validkey = 1'b1;
			end
			
			pressedJ:
			begin
				lcdKey = 8'h4A;
				validkey = 1'b1;
			end
			
			pressedK:
			begin
				lcdKey = 8'h4B;
				validkey = 1'b1;
			end
			
			pressedL:
			begin
				lcdKey = 8'h4C;
				validkey = 1'b1;
			end
			
			pressedM:
			begin
				lcdKey = 8'h4D;
				validkey = 1'b1;
			end
			
			pressedN:
			begin
				lcdKey = 8'h4E;
				validkey = 1'b1;
			end
			
			pressedO:
			begin
				lcdKey = 8'h4F;
				validkey = 1'b1;
			end
			
			pressedP:
			begin
				lcdKey = 8'h50;
				validkey = 1'b1;
			end
			
			pressedQ:
			begin
				lcdKey = 8'h51;
				validkey = 1'b1;
			end
			
			pressedR:
			begin
				lcdKey = 8'h52;
				validkey = 1'b1;
			end
			
			pressedS:
			begin
				lcdKey = 8'h53;
				validkey = 1'b1;
			end
			
			pressedT:
			begin
				lcdKey = 8'h54;
				validkey = 1'b1;
			end
			
			pressedU:
			begin
				lcdKey = 8'h55;
				validkey = 1'b1;
			end
			
			pressedV:
			begin
				lcdKey = 8'h56;
				validkey = 1'b1;
			end
			
			pressedW:
			begin
				lcdKey = 8'h57;
				validkey = 1'b1;
			end
			
			pressedX:
			begin
				lcdKey = 8'h58;
				validkey = 1'b1;
			end
			
			pressedY:
			begin
				lcdKey = 8'h59;
				validkey = 1'b1;
			end
			
			pressedZ:
			begin
				lcdKey = 8'h5A;
				validkey = 1'b1;
			end
			
			pressedENTER:
			begin
				lcdKey = 8'h23;
				validkey = 1'b1;
			end
			
			pressedSPACE:
			begin
				lcdKey = 8'h20;
				validkey = 1'b1;
			end
			
			pressedBACK:
			begin
				lcdKey = 8'h2D;
				validkey = 1'b1;
			end
			
			default:
			begin
				validkey = 1'b0;
			end
			
		endcase
	end
endmodule
